﻿import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 2.12
import QtMultimedia 5.14
import "../components/"

Rectangle {
    id: root
//    title: "报告文件"
//    modality: Qt.WindowModal
//    flags: Qt.Window | Qt.WindowTitleHint |Qt.WindowSystemMenuHint | Qt.WindowCloseButtonHint

//    signal accepted()
//    signal rejected()

    onVisibleChanged: {
        edit_path.setText(CReport.getExportPath())
        exportType = CReport.getExportType()
        button_autoExport.checked = CReport.getAutoExport()
    }

    property int exportType: 0      // 0:Word 1:Excel 2:CSV

//    height: 445*dp;  width: 666*dp
    radius: 4*dp

    Row{
        spacing: 10*dp
        x: (parent.width-540*dp)*0.5;  y: 60*dp
        CustomInputText{
            id: edit_path
            titleWidth: 100*dp
            editWidth: 310*dp
            title: "报告导出路径"
            editable: false
        }
        PushButton{
            defaultMode2: true
            title: "选择路径"
            onReleased: {
                let path = CReport.selectExportPath()
                if(path !== ""){
                    edit_path.setText(path)
                }
            }
        }
    }

    Row{
        spacing: 10*dp
        x: (parent.width-540*dp)*0.5;  y: 120*dp
        Item{
            width: 90*dp; height: 85*dp
            Text {
                anchors.verticalCenter: parent.verticalCenter
                width: 90*dp
                text: "导出文件类型"
                font.pixelSize: config.fontsize
            }
        }
        ExportTypeItem{
            checked: exportType === 0
            title: "Word"
            color_selected: "#1677FF"
            icon_source: "qrc:/picture/exportItem_word.png"
            onClicked: {
                exportType = 0
            }
        }
//        ExportTypeItem{
//            checked: exportType === 1
//            title: "Excel"
//            color_selected: Qt.rgba(3/255, 159/255, 0, 0.9)
//            icon_source: "qrc:/picture/exportItem_excel.png"
//            onClicked: {
//                exportType = 1
//            }
//        }
//        ExportTypeItem{
//            checked: exportType === 2
//            title: "Csv"
//            color_selected: Qt.rgba(3/255, 159/255, 0, 0.9)
//            icon_source: "qrc:/picture/exportItem_csv.png"
//            onClicked: {
//                exportType = 2
//            }
//        }
    }
    Row{
        x: (parent.width-540*dp)*0.5;  y: 230*dp
        spacing: 10*dp
        Text {
            anchors.verticalCenter: parent.verticalCenter
            width: 100*dp
            text: "是否自动导出"
            font.pixelSize: config.fontsize
        }
        CustomSwitchButton{
            id: button_autoExport
        }
    }

    Item{

        y: 500*dp
        width: root.width;  height: 40*dp

		PushButton{
            anchors.centerIn: parent
            title: "确定"
            defaultMode1: true
            onReleased: {
                CReport.updateExportInfo(edit_path.getText(), exportType, button_autoExport.checked)
//                root.accepted()
//                root.close()
                toast_settings.show("保存成功", 0)
            }
        }
    }


}
